package android.slc.module.user.repository.remote;

import android.slc.base.api.slc.callback.po.SlcEntity;
import android.slc.module.user.entity.User;
import android.slc.rx.SlcRxJavaUtils;
import io.reactivex.rxjava3.core.Observable;
import io.reactivex.rxjava3.functions.Function;
import org.jetbrains.annotations.NotNull;

import java.util.concurrent.TimeUnit;

/**
 * @author slc
 * @date 2022/09/19 下午 7:41
 */
public class UserServiceRepository {

    /**
     * 用户登录
     *
     * @param account
     * @param password
     * @return
     */
    public static Observable<SlcEntity<User>> login(String account, String password) {
        return Observable.timer(1000, TimeUnit.MILLISECONDS)
                .map(new Function<Long, SlcEntity<User>>() {
                    @Override
                    public SlcEntity<User> apply(@NotNull Long aLong) throws Exception {
                        User user = new User();
                        user.setId(1);
                        user.setUserName(account);
                        user.setPassword(password);
                        user.setNickName("Virtual User");
                        return SlcEntity.getSlcEntityByData(user);
                    }
                })
                .compose(SlcRxJavaUtils.applyOoAndroidSchedulers());

    }
}
